shadowCompat

fun Modifier.shadowCompat(elevation: Dp, shape: Shape = RectangleShape, clip: Boolean = elevation > 0.dp, ambientColor: Color = DefaultShadowColor, spotColor: Color = DefaultShadowColor, colorCompat: Color? = null, forceColorCompat: Boolean = false): Modifier

Creates a shadow replacement that can be tinted with the library's color compat mechanism on API levels before 28, the earliest version to support the native shadow colors.

Since this function is essentially an extension of the regular one, please refer to shadow's documentation for details regarding the first five parameters: elevation, shape, clip, ambientColor, and spotColor.

colorCompat takes a Color that's used to flatly tint a plain black shadow, since it's not possible to tint the ambient and spot separately at this level. The parameter is nullable to allow a special behavior: if it's null, the colorCompat value is automatically calculated as a blend of the ambientColor and spotColor, mixed in proportion to their current theme alphas. Setting any non-null value disables this behavior.

NB: The color blending formula that's currently used gives good results only if the ambient and spot colors are both fully opaque; i.e., only if both have maximum alpha values.

forceColorCompat is available to force the color compat tinting to be used on API levels 28 and above, for the purposes of testing, consistency, etc.